package jiyun.com.yiyanmeng;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.androidkun.xtablayout.XTabLayout;

import java.util.ArrayList;

import adapter.AboutMePagerAdapter;
import base.BaseFragment;

public class LunTanAboutMeActivity extends AppCompatActivity implements View.OnClickListener {

    /**
     * 返回
     */
    private TextView mImageBack;
    /**
     * 详情
     */
    private TextView mTvTitle;
    private TextView mTvRight;
    private RelativeLayout mRl;
    private FrameLayout mRlMain;
    private XTabLayout mTabs;
    private ViewPager mVp;
    private WenZhangReplyFra wenZhangReplyFra;
    private TieZiReplyFra tizi;
    private MeReplyFra meReplyFra;
    private ArrayList <Fragment> fragments;
    private AboutMePagerAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_luntan_about_me);
        initView();
    }

    private void initView() {
        mImageBack = (TextView) findViewById(R.id.image_back);
        mTvTitle = (TextView) findViewById(R.id.tv_title);
        mTvRight = (TextView) findViewById(R.id.tv_right);
        mRl = (RelativeLayout) findViewById(R.id.rl);
        mRlMain = (FrameLayout) findViewById(R.id.rl_main);
        mTabs = (XTabLayout) findViewById(R.id.tabs);
        mVp = (ViewPager) findViewById(R.id.vp);
        mImageBack.setOnClickListener(this);
        initData();
    }

    private void initData() {
        ArrayList <String> titles = new ArrayList <>();
        titles.add("文章回复");
        titles.add("帖子回复");
        titles.add("我的帖子");

        fragments = new ArrayList<>();
        wenZhangReplyFra = new WenZhangReplyFra();
        tizi = new TieZiReplyFra();
        meReplyFra = new MeReplyFra();
        fragments.add(wenZhangReplyFra);
        fragments.add(tizi);
        fragments.add(meReplyFra);

        adapter = new AboutMePagerAdapter(getSupportFragmentManager(), titles, fragments);
        mVp.setAdapter(adapter);
        mTabs.setupWithViewPager(mVp);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            default:
                break;
            case R.id.image_back://返回键
                finish();
                break;
        }
    }
}
